package com.xd.common.exception;

import com.xd.community.model.response.ErrorResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @Author: 林顺
 * @Date: 2021/11/18 21:57
 * 全局異常處理器
 */
@ControllerAdvice
public class GlobalExceptionHandler{

    @ExceptionHandler(value = BizException.class)
    public ErrorResponse catchBizException(BizException e) {
        ErrorResponse errorResponse = new ErrorResponse();
        errorResponse.setStatus(e.getStatus());
        errorResponse.setMessage(e.getMessage());
        return errorResponse;
    }

}
